package com.css.ids.server.service.dao;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.css.apps.base.dict.model.SDict;
import com.css.apps.base.dict.service.QueryDict;

public class IdsDictDao {

	@SuppressWarnings("unchecked")
	public static List<SDict> getDicts(Collection<String> dictIds) {
        return new QueryDict().idToObject(SDict.class, new ArrayList<>(dictIds));
    }
	
	@SuppressWarnings("static-access")
	public static SDict queryDictByTableCode(String table, String code) {
        String hql = "select uuid from SDict where tableName = :table and code = :code";
        QueryDict qc = (QueryDict) new QueryDict(hql).setParameter("table", table).setParameter("code", code);
        return qc.get(SDict.class, (String) qc.uniqueResult());
    }

    @SuppressWarnings("unchecked")
	public static List<SDict> queryDictsByTable(String table) {
        String hql = "from SDict where tableName = :table";
        QueryDict qc = (QueryDict) new QueryDict(hql).setParameter("table", table);
        return qc.list();
    }
	
}
